<template>
  <div style="position: relative">
    <div style="position: sticky;top: 0;z-index: 999;padding-top: 20px;background-color: white;padding-bottom: 20px">
      <div class="table_Header">
        <el-row :gutter="24">
          <el-col :span="3">
            <div class="align_items">
              <span class="table_HeaderTitle">创建日期</span>
            </div>
          </el-col>
          <el-col :span="2">
            <div class="align_items">
              <span class="table_HeaderTitle">类型</span>
            </div>
          </el-col>
          <el-col :span="5">
            <div class="align_items">
              <span class="table_HeaderTitle">订单摘要</span>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="align_items">
              <span class="table_HeaderTitle">买家信息</span>
            </div>
          </el-col>
          <el-col :span="2">
            <div class="align_items">
              <span class="table_HeaderTitle">付款状态</span>
            </div>
          </el-col>
          <el-col :span="2">
            <div class="align_items">
              <span class="table_HeaderTitle">金额</span>
            </div>
          </el-col>
          <el-col :span="3">
            <div class="align_items">
              <span class="table_HeaderTitle">收款时间</span>
            </div>
          </el-col>
          <el-col :span="3">
            <div class="justify_right">
              <span class="table_HeaderTitle">操作</span>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="table_List" v-for="item in payments">
      <div class="table_ListHeader">
        <div class="align_items">
          <span class="table_ListHeaderTitle">收款单号：{{item.sn}}</span>
        </div>
        <div class="align_items">
          <span class="table_ListHeaderTitle">付款方式：{{item.paymentPluginName}}</span>
        </div>
      </div>
      <div style="padding: 10px">
        <el-row :gutter="24">
          <el-col :span="3">
            <div class="align_items shop_Height">
              <span class="table_ContentTitle">{{item.createDate|datetimeFormatter}}</span>
            </div>
          </el-col>
          <el-col :span="2">
            <div class="align_items shop_Height">
              <span class="table_ContentTitle">{{item.type|watchType}}</span>
            </div>
          </el-col>
          <el-col :span="5">
            <div class="align_items shop_Height">
              <span class="table_ContentTitle">{{item.memo}}</span>
            </div>
          </el-col>
          <el-col :span="4">
            <div style="display: flex;flex-direction: column;justify-content: center" class="shop_Height">
              <span style="margin-top: 5px" class="table_ContentTitle">{{item.name}}({{item.mobile}})</span>
            </div>
          </el-col>
          <el-col :span="2">
            <div class="align_items shop_Height">
              <span class="table_ContentTitle">{{item.status|watchStatus}}</span>
            </div>
          </el-col>
          <el-col :span="2">
            <div class="align_items shop_Height">
              <span class="table_ContentTitle">{{item.amount}}</span>
            </div>
            <div class="align_items shop_Height" v-if="item.refund!=0">
              <span class="table_ContentTitle_return">已退:{{item.refund}}</span>
            </div>
          </el-col>
          <el-col :span="3">
            <div class="align_items shop_Height">
              <span class="table_ContentTitle">{{item.paymentDate | datetimeFormatter}}</span>
            </div>
          </el-col>
          <el-col :span="3">
            <div class="justify_right shop_Height" @click="detailsClick(item.id)">
              <a class="details_Title">订单详情</a>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'list',
    props:['payments'],
    filters:{
      watchStatus(val){
        if (val == 0){
          return '等待支付'
        } else if (val == 1){
          return '支付成功'
        }else if (val == 2){
          return '超时关闭'
        } else if (val == 3){
          return '支付失败'
        }
      },
      watchMethod(val){
        if (val===0){
          return '线上支付'
        }else if (val===1){
          return '线下支付'
        }
      },
      watchType(val){
        if (val===0){
          return '订单支付'
        }else if (val===1){
          return '钱包充值'
        }else if (val===2){
          return '线下收款'
        }
      }
    },
    methods:{
      detailsClick(id){
        this.$emit('detailsClick',id)
      }
    }
  }
</script>

<style scoped>
  .table_Header {
    width: 100%;
    background-color: #f5f7fa;
    padding: 10px;
  }

  .table_HeaderTitle {
    font-size: 12px;
    color: #353535;
    font-weight: 600;
  }
  .table_List{
    width: 100%;
    margin-bottom: 20px;
    border: 1px solid #f2f2f2;
  }
  .table_ListHeader{
    width: 100%;
    padding: 10px;
    background-color: #f5f7fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .table_ListHeaderTitle{
    font-size: 12px;
    color: #888888;
  }
  .align_items{
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .justify_left{
    display: flex;
    align-items: center;
  }
  .justify_right{
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  .table_ContentTitle {
    font-size: 12px;
    color: #353535;
    width: 100%;
    text-align: center;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .table_ContentTitle_return{
    font-size: 12px;
    color: red;
    width: 100%;
    text-align: center;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .shop_Height{
    min-height: 30px;
  }
  .details_Title{
    font-size: 14px;
    color: #409EFF;
  }
</style>
